package com.gnerv.sylvanas.business.manage.operation;

import com.gnerv.sylvanas.framework.core.BaseCurrentAccount;
import com.gnerv.sylvanas.business.manage.model.bo.PostBO;
import com.gnerv.sylvanas.business.manage.model.dto.PostDTO;
import com.gnerv.sylvanas.business.manage.model.entity.Post;
import com.gnerv.sylvanas.business.manage.storage.PostStorageService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Gnerv LiGen
 */
@Service
@AllArgsConstructor
public class PostOperationService {

    private final PostStorageService postStorageService;
    private final BaseCurrentAccount baseCurrentAccount;

    
    public boolean create(PostBO postBO) {
        Post post = postBO.toPost();
        
        postStorageService.insert(post);
        return true;
    }

    
    public boolean deleteByUkId(String ukId) {
        postStorageService.deleteByUkId(ukId);
        return true;
    }

    
    public boolean updateByUkId(PostBO postBO) {
        Post post = postBO.toPost();
        postStorageService.updateByUkId(post);
        return true;
    }

    
    public PostDTO selectByUkId(String ukId) {
        return postStorageService.selectByUkId(ukId);
    }

    
    public PostDTO selectByName(String name) {
        return postStorageService.selectByName(name);
    }

    
    public List<PostDTO> selectListByName(String name) {
        return postStorageService.selectListByName(name);
    }

    
    public boolean bindOrg(String postUkId, String orgUkId) {
        postStorageService.bindOrg(postUkId, orgUkId, baseCurrentAccount.ukId());
        return true;
    }

    
    public boolean unbindOrg(String postUkId) {
        postStorageService.unbindOrg(postUkId);
        return true;
    }

}




